<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'DejaVu Sans'; font-size:11pt; font-weight:400; font-style:normal;">
<html>

<div class="entry-header" style="box-sizing: border-box; text-align: var(--textalign,center); --textalign: left; margin-top: 60px; margin-bottom: var(--spacing,60px); color: rgb(39, 38, 38); font-family: Arial, Helvetica, sans-serif, Arial, Helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="nv-title-meta-wrap" style="box-sizing: border-box;"><h1 class="title entry-title" style="box-sizing: border-box; margin: 0px 0px 10px; padding: 0px; font-size: var(--fontsize,var(--h1fontsize)); font-weight: var(--fontweight,var(--h1fontweight)); font-family: var(--headingsfontfamily),var(--nv-fallback-ff);  letter-spacing: var(--letterspacing,var(--h1letterspacing)); text-transform: var(--texttransform,var(--h1texttransform)); overflow-wrap: break-word;">VBA Excel. Выбор случайной ячейки</h1><ul class="nv-meta-list" style="box-sizing: border-box; margin: 0px 0px 20px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: var(--listpad,0); list-style: var(--liststyle,none); font-size: 0.9em; --avatarsize: 20px;"></ul></div></div><div class="nv-content-wrap entry-content" style="box-sizing: border-box; counter-reset: footnotes 0; --listpad: 20px; --liststyle: disc; --img-m: 24px; margin-bottom: var(--spacing,60px); color: rgb(39, 38, 38); font-family: Arial, Helvetica, sans-serif, Arial, Helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; height: auto !important;"><p style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;"><em style="box-sizing: border-box;">Выбор случайной ячейки из диапазона Excel с помощью кода VBA и присвоение ее значения переменной. Заполнение диапазона ячеек случайными числами.</em><span id="more-3297" style="box-sizing: border-box;"></span></p><div class="lwptoc lwptoc-autoWidth lwptoc-baseItems lwptoc-light lwptoc-notInherit" data-smooth-scroll="1" data-smooth-scroll-offset="24" data-lwptoc-initialized="1" style="box-sizing: border-box; margin: 32px 0px;"><div class="lwptoc_i" style="box-sizing: border-box; padding: 14px 18px 18px; text-align: left; display: inline-block; color: rgb(51, 51, 51); background: rgb(250, 250, 250);"><div class="lwptoc_header" style="box-sizing: border-box; margin-bottom: 6px;"><b class="lwptoc_title" style="box-sizing: border-box; font-weight: 600;">Содержание</b></div><div class="lwptoc_items lwptoc_items-visible" style="box-sizing: border-box; font-size: 14.4px;"><div class="lwptoc_itemWrap" style="box-sizing: border-box;"><div class="lwptoc_item" style="box-sizing: border-box; margin-top: 0px;"><a href="https://vremya-ne-zhdet.ru/vba-excel/vybor-sluchaynoy-yacheyki/#Vybor_slucajnoj_acejki_iz_diapazona" style="box-sizing: border-box; --linkdeco: underline; color: rgb(49, 117, 228); cursor: pointer; text-decoration: none !important; box-shadow: none !important; border: none !important;"><span class="lwptoc_item_number" style="box-sizing: border-box; margin-right: 2px;">1.</span><span> </span><span class="lwptoc_item_label" style="box-sizing: border-box;">Выбор случайной ячейки из диапазона</span></a><div class="lwptoc_itemWrap" style="box-sizing: border-box; margin: 2px 0px 0px 14px;"><div class="lwptoc_item" style="box-sizing: border-box; margin-top: 0px;"><a href="https://vremya-ne-zhdet.ru/vba-excel/vybor-sluchaynoy-yacheyki/#Zadanie" style="box-sizing: border-box; --linkdeco: underline; color: rgb(49, 117, 228); cursor: pointer; text-decoration: none !important; box-shadow: none !important; border: none !important;"><span class="lwptoc_item_number" style="box-sizing: border-box; margin-right: 2px;">1.1.</span><span> </span><span class="lwptoc_item_label" style="box-sizing: border-box;">Задание</span></a></div><div class="lwptoc_item" style="box-sizing: border-box; margin-top: 2px;"><a href="https://vremya-ne-zhdet.ru/vba-excel/vybor-sluchaynoy-yacheyki/#Resenie" style="box-sizing: border-box; --linkdeco: underline; color: rgb(49, 117, 228); cursor: pointer; text-decoration: none !important; box-shadow: none !important; border: none !important;"><span class="lwptoc_item_number" style="box-sizing: border-box; margin-right: 2px;">1.2.</span><span> </span><span class="lwptoc_item_label" style="box-sizing: border-box;">Решение</span></a></div></div></div><div class="lwptoc_item" style="box-sizing: border-box; margin-top: 2px;"><a href="https://vremya-ne-zhdet.ru/vba-excel/vybor-sluchaynoy-yacheyki/#Zapolnenie_aceek_slucajnymi_cislami" style="box-sizing: border-box; --linkdeco: underline; color: rgb(49, 117, 228); cursor: pointer; text-decoration: none !important; box-shadow: none !important; border: none !important;"><span class="lwptoc_item_number" style="box-sizing: border-box; margin-right: 2px;">2.</span><span> </span><span class="lwptoc_item_label" style="box-sizing: border-box;">Заполнение ячеек случайными числами</span></a><div class="lwptoc_itemWrap" style="box-sizing: border-box; margin: 2px 0px 0px 14px;"><div class="lwptoc_item" style="box-sizing: border-box; margin-top: 0px;"><a href="https://vremya-ne-zhdet.ru/vba-excel/vybor-sluchaynoy-yacheyki/#Zadanie1" style="box-sizing: border-box; --linkdeco: underline; color: rgb(49, 117, 228); cursor: pointer; text-decoration: none !important; box-shadow: none !important; border: none !important;"><span class="lwptoc_item_number" style="box-sizing: border-box; margin-right: 2px;">2.1.</span><span> </span><span class="lwptoc_item_label" style="box-sizing: border-box;">Задание</span></a></div><div class="lwptoc_item" style="box-sizing: border-box; margin-top: 2px;"><a href="https://vremya-ne-zhdet.ru/vba-excel/vybor-sluchaynoy-yacheyki/#Resenie1" style="box-sizing: border-box; --linkdeco: underline; color: rgb(49, 117, 228); cursor: pointer; text-decoration: none !important; box-shadow: none !important; border: none !important;"><span class="lwptoc_item_number" style="box-sizing: border-box; margin-right: 2px;">2.2.</span><span> </span><span class="lwptoc_item_label" style="box-sizing: border-box;">Решение</span></a></div></div></div></div></div></div></div><h2 style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; font-size: var(--h2fontsize); font-weight: var(--h2fontweight); font-family: var(--headingsfontfamily),var(--nv-fallback-ff);  letter-spacing: var(--h2letterspacing); text-transform: var(--h2texttransform);"><span id="Vybor_slucajnoj_acejki_iz_diapazona" style="box-sizing: border-box;">Выбор случайной ячейки из диапазона</span></h2><h3 style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; font-size: var(--h3fontsize); font-weight: var(--h3fontweight); font-family: var(--headingsfontfamily),var(--nv-fallback-ff);  letter-spacing: var(--h3letterspacing); text-transform: var(--h3texttransform);"><span id="Zadanie" style="box-sizing: border-box;">Задание</span></h3><p style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;">Необходимо написать код VBA Excel для кнопки, при нажатии на которую выбирается случайная ячейка из заданного диапазона и ее значение присваивается переменной.</p><h3 style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; font-size: var(--h3fontsize); font-weight: var(--h3fontweight); font-family: var(--headingsfontfamily),var(--nv-fallback-ff);  letter-spacing: var(--h3letterspacing); text-transform: var(--h3texttransform);"><span id="Resenie" style="box-sizing: border-box;">Решение</span></h3><p style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;">Для решения поставленной задачи в качестве произвольного диапазона ячеек отлично подойдет объект Selection, который при тестировании кода позволит не менять адрес диапазона в процедуре, а выбирать его непосредственно на рабочем листе.</p><div id="attachment_3298" class="wp-caption aligncenter" style="box-sizing: border-box; clear: both; display: block; text-align: center; margin: 0px auto; max-width: 100%; width: 548px;"><p id="caption-attachment-3298" class="wp-caption-text" style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; text-align: center; font-size: 0.8em; font-weight: 500;">Выделенный диапазон для выбора случайной ячейки</p></div><p style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;">Кнопка CommandButton1 добавлена из набора элементов управления рабочего листа ActiveX.<span> </span><a href="https://vremya-ne-zhdet.ru/vba-excel/modul-protsedura-forma/" style="box-sizing: border-box; --linkdeco: underline; color: var(--nv-primary-accent); cursor: pointer; text-decoration: var(--linkdeco);">Модуль</a><span> </span>листа открывается двойным кликом по кнопке в режиме конструктора.</p><p style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;">Для выбора случайной ячейки будем использовать свойство диапазона Cells,<span> </span><a href="https://vremya-ne-zhdet.ru/vba-excel/generator-sluchaynykh-chisel/" style="box-sizing: border-box; --linkdeco: underline; color: var(--nv-primary-accent); cursor: pointer; text-decoration: var(--linkdeco);">функцию Rnd</a><span> </span>и оператор Randomize, инициализирующий генератор случайных чисел функции Rnd и задающий начальное число для генерации первого псевдослучайного числа.</p><div class="google-auto-placed ap_container" style="box-sizing: border-box; width: 960px; height: auto; clear: both; text-align: center;"><ins data-ad-format="auto" class="adsbygoogle adsbygoogle-noablate" data-ad-client="ca-pub-3460721053602142" data-adsbygoogle-status="done" data-ad-status="unfilled" style="box-sizing: border-box; text-decoration: none; display: block; margin: auto; background-color: transparent; height: 0px;"><div id="aswift_1_host" tabindex="0" title="Advertisement" aria-label="Advertisement" style="box-sizing: border-box; border: none; height: 0px; width: 960px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: inline-block; overflow: hidden; opacity: 0;"><iframe id="aswift_1" name="aswift_1" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" width="960" height="0" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" src="https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-3460721053602142&amp;output=html&amp;h=280&amp;adk=4198996889&amp;adf=2720407464&amp;pi=t.aa~a.2994879612~i.18~rp.4&amp;w=960&amp;fwrn=4&amp;fwrnh=100&amp;lmt=1694542433&amp;num_ads=1&amp;rafmt=1&amp;armr=3&amp;sem=mc&amp;pwprc=9507011714&amp;ad_type=text_image&amp;format=960x280&amp;url=https%3A%2F%2Fvremya-ne-zhdet.ru%2Fvba-excel%2Fvybor-sluchaynoy-yacheyki%2F&amp;fwr=0&amp;pra=3&amp;rh=200&amp;rw=960&amp;rpe=1&amp;resp_fmts=3&amp;wgl=1&amp;fa=27&amp;uach=WyJXaW5kb3dzIiwiMTUuMC4wIiwieDg2IiwiIiwiMjMuNy40Ljk3MSIsW10sMCxudWxsLCI2NCIsW1siTm90LkEvQnJhbmQiLCI4LjAuMC4wIl0sWyJDaHJvbWl1bSIsIjExNC4wLjU3MzUuMjg5Il0sWyJZYUJyb3dzZXIiLCIyMy43LjQuOTcxIl1dLDBd&amp;dt=1694540732837&amp;bpp=4&amp;bdt=21019&amp;idt=4&amp;shv=r20230907&amp;mjsv=m202309120101&amp;ptt=9&amp;saldr=aa&amp;abxe=1&amp;cookie=ID%3Db9bebb71368c25f3-2201b9ef68de007a%3AT%3D1694115878%3ART%3D1694540739%3AS%3DALNI_Ma3frN0cXirUHyuAOLWfMkqZEMxuA&amp;gpic=UID%3D00000d90c82ba053%3AT%3D1694115878%3ART%3D1694540739%3AS%3DALNI_MYSu2HMUV4-wrBhZkUsdUg0v0y7zw&amp;prev_fmts=0x0&amp;nras=2&amp;correlator=8553361513783&amp;frm=20&amp;pv=1&amp;ga_vid=133512174.1694115766&amp;ga_sid=1694540721&amp;ga_hid=1247311596&amp;ga_fc=1&amp;u_tz=180&amp;u_his=2&amp;u_h=864&amp;u_w=1536&amp;u_ah=816&amp;u_aw=1536&amp;u_cd=24&amp;u_sd=1.125&amp;dmc=8&amp;adx=337&amp;ady=1738&amp;biw=1635&amp;bih=796&amp;scr_x=0&amp;scr_y=0&amp;eid=44759875%2C44759926%2C44759842%2C31077327%2C31077838&amp;oid=2&amp;pvsid=3453566974728970&amp;tmod=371194068&amp;uas=0&amp;nvt=1&amp;ref=https%3A%2F%2Fvremya-ne-zhdet.ru%2Fcategory%2Fvba-excel%2Fpage%2F7%2F&amp;fc=1408&amp;brdim=0%2C0%2C0%2C0%2C1536%2C0%2C0%2C0%2C1653%2C796&amp;vis=1&amp;rsz=%7C%7Cs%7C&amp;abl=NS&amp;fu=128&amp;bc=31&amp;ifi=2&amp;uci=a!2&amp;btvi=1&amp;fsb=1&amp;xpc=SW9yyGgclm&amp;p=https%3A//vremya-ne-zhdet.ru&amp;dtd=M" data-google-container-id="a!2" data-google-query-id="CKfm_L3WpYEDFcZdkQUdIiAMbg" data-load-complete="true" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; max-width: 100%; left: 0px; position: absolute; top: 0px; width: 960px; height: 0px;"></iframe></div></ins></div><p style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;">1. Объявляем переменную x с универсальным типом данных (Variant), так как в конечном итоге ей будет присваиваться содержимое случайной ячейки, которое может быть любым:</p><div id="urvanov-syntax-highlighter-6500a3a6a7bcc638957535" class="urvanov-syntax-highlighter-syntax crayon-theme-classic urvanov-syntax-highlighter-font-verdana urvanov-syntax-highlighter-os-pc print-yes notranslate" data-settings=" no-popup minimize scroll-always" style="box-sizing: border-box; text-align: left; text-size-adjust: none; overflow: hidden !important; position: relative !important; direction: ltr !important; width: 960px; padding: 0px; margin: 12px 0px; font-family: Monaco, MonacoRegular, &quot;Courier New&quot;, monospace; font-weight: 500; border-width: 1px !important; border-color: rgb(153, 153, 153) !important; border-style: solid !important; text-shadow: none !important; background: rgb(253, 253, 253) !important; font-size: 12px !important;  height: auto;"><div class="urvanov-syntax-highlighter-plain-wrap" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px !important; margin: 0px !important; text-align: left; height: auto !important;"></div><div class="urvanov-syntax-highlighter-main" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px; margin: 0px; text-align: left; width: 958.222px; overflow: auto; position: relative; z-index: 1;"><table class="crayon-table" style="box-sizing: border-box; border-collapse: collapse !important; border-spacing: 0px !important; border: none !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px; width: auto !important; word-break: initial; font-family: Verdana, Arial, sans !important; padding: 0px !important; background: none !important; table-layout: auto !important;"><tbody style="box-sizing: border-box; font-family: Verdana, Arial, sans !important;"><tr class="urvanov-syntax-highlighter-row" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; padding: 0px !important; border: none !important; background: none !important; vertical-align: top !important; margin: 0px !important;"><td class="crayon-nums " data-settings="show" style="box-sizing: border-box; padding: 0px !important; text-align: left; font-size: 0.9em; border: none !important; background: rgb(223, 239, 255) !important; font-family: Verdana, Arial, sans !important; user-select: none; vertical-align: top !important; margin: 0px !important; color: rgb(84, 153, 222) !important;"><div class="urvanov-syntax-highlighter-nums-content" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px; margin: 0px; text-align: left; white-space: nowrap; font-size: 12px !important; "><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bcc638957535-1" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">1</div></div></td><td class="urvanov-syntax-highlighter-code" style="box-sizing: border-box; padding: 0px !important; text-align: left; font-size: 0.9em; border: none !important; background: none !important; font-family: Verdana, Arial, sans !important; width: 940.583px; vertical-align: top !important; margin: 0px !important;"><div class="crayon-pre" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: none !important; border: none !important; padding: 0px; margin: 0px; text-align: left; color: rgb(0, 0, 0); white-space: pre; overflow: visible; tab-size: 4; font-size: 12px !important; "><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7bcc638957535-1" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-r" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Dim</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-i" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 0, 0) !important;">x</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">As</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-r" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Variant</span></div></div></td></tr></tbody></table></div></div><p style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;">2. Определяем количество ячеек в выделенном диапазоне:</p><div id="urvanov-syntax-highlighter-6500a3a6a7bd8596998243" class="urvanov-syntax-highlighter-syntax crayon-theme-classic urvanov-syntax-highlighter-font-verdana urvanov-syntax-highlighter-os-pc print-yes notranslate" data-settings=" no-popup minimize scroll-always" style="box-sizing: border-box; text-align: left; text-size-adjust: none; overflow: hidden !important; position: relative !important; direction: ltr !important; width: 960px; padding: 0px; margin: 12px 0px; font-family: Monaco, MonacoRegular, &quot;Courier New&quot;, monospace; font-weight: 500; border-width: 1px !important; border-color: rgb(153, 153, 153) !important; border-style: solid !important; text-shadow: none !important; background: rgb(253, 253, 253) !important; font-size: 12px !important;  height: auto;"><div class="urvanov-syntax-highlighter-plain-wrap" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px !important; margin: 0px !important; text-align: left; height: auto !important;"></div><div class="urvanov-syntax-highlighter-main" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px; margin: 0px; text-align: left; width: 958.222px; overflow: auto; position: relative; z-index: 1;"><table class="crayon-table" style="box-sizing: border-box; border-collapse: collapse !important; border-spacing: 0px !important; border: none !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px; width: auto !important; word-break: initial; font-family: Verdana, Arial, sans !important; padding: 0px !important; background: none !important; table-layout: auto !important;"><tbody style="box-sizing: border-box; font-family: Verdana, Arial, sans !important;"><tr class="urvanov-syntax-highlighter-row" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; padding: 0px !important; border: none !important; background: none !important; vertical-align: top !important; margin: 0px !important;"><td class="crayon-nums " data-settings="show" style="box-sizing: border-box; padding: 0px !important; text-align: left; font-size: 0.9em; border: none !important; background: rgb(223, 239, 255) !important; font-family: Verdana, Arial, sans !important; user-select: none; vertical-align: top !important; margin: 0px !important; color: rgb(84, 153, 222) !important;"><div class="urvanov-syntax-highlighter-nums-content" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px; margin: 0px; text-align: left; white-space: nowrap; font-size: 12px !important; "><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bd8596998243-1" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">1</div></div></td><td class="urvanov-syntax-highlighter-code" style="box-sizing: border-box; padding: 0px !important; text-align: left; font-size: 0.9em; border: none !important; background: none !important; font-family: Verdana, Arial, sans !important; width: 940.583px; vertical-align: top !important; margin: 0px !important;"><div class="crayon-pre" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: none !important; border: none !important; padding: 0px; margin: 0px; text-align: left; color: rgb(0, 0, 0); white-space: pre; overflow: visible; tab-size: 4; font-size: 12px !important; "><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7bd8596998243-1" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">x</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">=</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">Selection</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">.</span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">Count</span></div></div></td></tr></tbody></table></div></div><p style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;">3. Инициируем генератор случайных чисел функции Rnd, используя оператор Randomize без аргумента:</p><div id="urvanov-syntax-highlighter-6500a3a6a7bda244735435" class="urvanov-syntax-highlighter-syntax crayon-theme-classic urvanov-syntax-highlighter-font-verdana urvanov-syntax-highlighter-os-pc print-yes notranslate" data-settings=" no-popup minimize scroll-always" style="box-sizing: border-box; text-align: left; text-size-adjust: none; overflow: hidden !important; position: relative !important; direction: ltr !important; width: 960px; padding: 0px; margin: 12px 0px; font-family: Monaco, MonacoRegular, &quot;Courier New&quot;, monospace; font-weight: 500; border-width: 1px !important; border-color: rgb(153, 153, 153) !important; border-style: solid !important; text-shadow: none !important; background: rgb(253, 253, 253) !important; font-size: 12px !important;  height: auto;"><div class="urvanov-syntax-highlighter-plain-wrap" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px !important; margin: 0px !important; text-align: left; height: auto !important;"></div><div class="urvanov-syntax-highlighter-main" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px; margin: 0px; text-align: left; width: 958.222px; overflow: auto; position: relative; z-index: 1;"><table class="crayon-table" style="box-sizing: border-box; border-collapse: collapse !important; border-spacing: 0px !important; border: none !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px; width: auto !important; word-break: initial; font-family: Verdana, Arial, sans !important; padding: 0px !important; background: none !important; table-layout: auto !important;"><tbody style="box-sizing: border-box; font-family: Verdana, Arial, sans !important;"><tr class="urvanov-syntax-highlighter-row" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; padding: 0px !important; border: none !important; background: none !important; vertical-align: top !important; margin: 0px !important;"><td class="crayon-nums " data-settings="show" style="box-sizing: border-box; padding: 0px !important; text-align: left; font-size: 0.9em; border: none !important; background: rgb(223, 239, 255) !important; font-family: Verdana, Arial, sans !important; user-select: none; vertical-align: top !important; margin: 0px !important; color: rgb(84, 153, 222) !important;"><div class="urvanov-syntax-highlighter-nums-content" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px; margin: 0px; text-align: left; white-space: nowrap; font-size: 12px !important; "><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bda244735435-1" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">1</div></div></td><td class="urvanov-syntax-highlighter-code" style="box-sizing: border-box; padding: 0px !important; text-align: left; font-size: 0.9em; border: none !important; background: none !important; font-family: Verdana, Arial, sans !important; width: 940.583px; vertical-align: top !important; margin: 0px !important;"><div class="crayon-pre" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: none !important; border: none !important; padding: 0px; margin: 0px; text-align: left; color: rgb(0, 0, 0); white-space: pre; overflow: visible; tab-size: 4; font-size: 12px !important; "><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7bda244735435-1" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">Randomize</span></div></div></td></tr></tbody></table></div></div><p style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;">В этом случае, в качестве аргумента оператора Randomize, используется текущее значение системного таймера.</p><p style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;">4. Выбираем случайный порядковый номер ячейки в выделенном диапазоне:</p><div id="urvanov-syntax-highlighter-6500a3a6a7bdd519789654" class="urvanov-syntax-highlighter-syntax crayon-theme-classic urvanov-syntax-highlighter-font-verdana urvanov-syntax-highlighter-os-pc print-yes notranslate" data-settings=" no-popup minimize scroll-always" style="box-sizing: border-box; text-align: left; text-size-adjust: none; overflow: hidden !important; position: relative !important; direction: ltr !important; width: 960px; padding: 0px; margin: 12px 0px; font-family: Monaco, MonacoRegular, &quot;Courier New&quot;, monospace; font-weight: 500; border-width: 1px !important; border-color: rgb(153, 153, 153) !important; border-style: solid !important; text-shadow: none !important; background: rgb(253, 253, 253) !important; font-size: 12px !important;  height: auto;"><div class="urvanov-syntax-highlighter-plain-wrap" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px !important; margin: 0px !important; text-align: left; height: auto !important;"></div><div class="urvanov-syntax-highlighter-main" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px; margin: 0px; text-align: left; width: 958.222px; overflow: auto; position: relative; z-index: 1;"><table class="crayon-table" style="box-sizing: border-box; border-collapse: collapse !important; border-spacing: 0px !important; border: none !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px; width: auto !important; word-break: initial; font-family: Verdana, Arial, sans !important; padding: 0px !important; background: none !important; table-layout: auto !important;"><tbody style="box-sizing: border-box; font-family: Verdana, Arial, sans !important;"><tr class="urvanov-syntax-highlighter-row" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; padding: 0px !important; border: none !important; background: none !important; vertical-align: top !important; margin: 0px !important;"><td class="crayon-nums " data-settings="show" style="box-sizing: border-box; padding: 0px !important; text-align: left; font-size: 0.9em; border: none !important; background: rgb(223, 239, 255) !important; font-family: Verdana, Arial, sans !important; user-select: none; vertical-align: top !important; margin: 0px !important; color: rgb(84, 153, 222) !important;"><div class="urvanov-syntax-highlighter-nums-content" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px; margin: 0px; text-align: left; white-space: nowrap; font-size: 12px !important; "><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bdd519789654-1" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">1</div></div></td><td class="urvanov-syntax-highlighter-code" style="box-sizing: border-box; padding: 0px !important; text-align: left; font-size: 0.9em; border: none !important; background: none !important; font-family: Verdana, Arial, sans !important; width: 940.583px; vertical-align: top !important; margin: 0px !important;"><div class="crayon-pre" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: none !important; border: none !important; padding: 0px; margin: 0px; text-align: left; color: rgb(0, 0, 0); white-space: pre; overflow: visible; tab-size: 4; font-size: 12px !important; "><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7bdd519789654-1" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">x</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">=</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">Round</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">(</span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">Rnd</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">*</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">(</span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">x</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">-</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-cn" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(206, 0, 0) !important;">1</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">)</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">,</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-cn" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(206, 0, 0) !important;">0</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">)</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">+</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-cn" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(206, 0, 0) !important;">1</span></div></div></td></tr></tbody></table></div></div><p style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;">Так как в выделенном диапазоне индексация ячеек начинается с единицы, прибавляем к округленному значению случайного числа, которое может быть равно нулю, единицу. Псевдослучайное число, возвращенное функцией Rnd, умножаем на число ячеек минус один, чтобы исключить результат, когда порядковый номер на единицу больше количества ячеек в выделенном диапазоне.</p><p style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;">5. Присваиваем значение случайной ячейки переменной x, используя свойство диапазона Cells:</p><div id="urvanov-syntax-highlighter-6500a3a6a7be1352757725" class="urvanov-syntax-highlighter-syntax crayon-theme-classic urvanov-syntax-highlighter-font-verdana urvanov-syntax-highlighter-os-pc print-yes notranslate" data-settings=" no-popup minimize scroll-always" style="box-sizing: border-box; text-align: left; text-size-adjust: none; overflow: hidden !important; position: relative !important; direction: ltr !important; width: 960px; padding: 0px; margin: 12px 0px; font-family: Monaco, MonacoRegular, &quot;Courier New&quot;, monospace; font-weight: 500; border-width: 1px !important; border-color: rgb(153, 153, 153) !important; border-style: solid !important; text-shadow: none !important; background: rgb(253, 253, 253) !important; font-size: 12px !important;  height: auto;"><div class="urvanov-syntax-highlighter-plain-wrap" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px !important; margin: 0px !important; text-align: left; height: auto !important;"></div><div class="urvanov-syntax-highlighter-main" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px; margin: 0px; text-align: left; width: 958.222px; overflow: auto; position: relative; z-index: 1;"><table class="crayon-table" style="box-sizing: border-box; border-collapse: collapse !important; border-spacing: 0px !important; border: none !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px; width: auto !important; word-break: initial; font-family: Verdana, Arial, sans !important; padding: 0px !important; background: none !important; table-layout: auto !important;"><tbody style="box-sizing: border-box; font-family: Verdana, Arial, sans !important;"><tr class="urvanov-syntax-highlighter-row" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; padding: 0px !important; border: none !important; background: none !important; vertical-align: top !important; margin: 0px !important;"><td class="crayon-nums " data-settings="show" style="box-sizing: border-box; padding: 0px !important; text-align: left; font-size: 0.9em; border: none !important; background: rgb(223, 239, 255) !important; font-family: Verdana, Arial, sans !important; user-select: none; vertical-align: top !important; margin: 0px !important; color: rgb(84, 153, 222) !important;"><div class="urvanov-syntax-highlighter-nums-content" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px; margin: 0px; text-align: left; white-space: nowrap; font-size: 12px !important; "><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7be1352757725-1" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">1</div></div></td><td class="urvanov-syntax-highlighter-code" style="box-sizing: border-box; padding: 0px !important; text-align: left; font-size: 0.9em; border: none !important; background: none !important; font-family: Verdana, Arial, sans !important; width: 940.583px; vertical-align: top !important; margin: 0px !important;"><div class="crayon-pre" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: none !important; border: none !important; padding: 0px; margin: 0px; text-align: left; color: rgb(0, 0, 0); white-space: pre; overflow: visible; tab-size: 4; font-size: 12px !important; "><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7be1352757725-1" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">x</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">=</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">Selection</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">.</span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">Cells</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">(</span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">x</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">)</span></div></div></td></tr></tbody></table></div></div><p style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;">Как известно, индексация ячеек в диапазонах осуществляется не только по строкам и столбцам, но и по порядковым номерам. Нумерация идет слева направо и сверху вниз, ее мы здесь и используем.</p><p style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;">6. Выводим значение переменной в информационное окно MsgBox:</p><div id="urvanov-syntax-highlighter-6500a3a6a7be4800529988" class="urvanov-syntax-highlighter-syntax crayon-theme-classic urvanov-syntax-highlighter-font-verdana urvanov-syntax-highlighter-os-pc print-yes notranslate" data-settings=" no-popup minimize scroll-always" style="box-sizing: border-box; text-align: left; text-size-adjust: none; overflow: hidden !important; position: relative !important; direction: ltr !important; width: 960px; padding: 0px; margin: 12px 0px; font-family: Monaco, MonacoRegular, &quot;Courier New&quot;, monospace; font-weight: 500; border-width: 1px !important; border-color: rgb(153, 153, 153) !important; border-style: solid !important; text-shadow: none !important; background: rgb(253, 253, 253) !important; font-size: 12px !important;  height: auto;"><div class="urvanov-syntax-highlighter-plain-wrap" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px !important; margin: 0px !important; text-align: left; height: auto !important;"></div><div class="urvanov-syntax-highlighter-main" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px; margin: 0px; text-align: left; width: 958.222px; overflow: auto; position: relative; z-index: 1;"><table class="crayon-table" style="box-sizing: border-box; border-collapse: collapse !important; border-spacing: 0px !important; border: none !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px; width: auto !important; word-break: initial; font-family: Verdana, Arial, sans !important; padding: 0px !important; background: none !important; table-layout: auto !important;"><tbody style="box-sizing: border-box; font-family: Verdana, Arial, sans !important;"><tr class="urvanov-syntax-highlighter-row" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; padding: 0px !important; border: none !important; background: none !important; vertical-align: top !important; margin: 0px !important;"><td class="crayon-nums " data-settings="show" style="box-sizing: border-box; padding: 0px !important; text-align: left; font-size: 0.9em; border: none !important; background: rgb(223, 239, 255) !important; font-family: Verdana, Arial, sans !important; user-select: none; vertical-align: top !important; margin: 0px !important; color: rgb(84, 153, 222) !important;"><div class="urvanov-syntax-highlighter-nums-content" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px; margin: 0px; text-align: left; white-space: nowrap; font-size: 12px !important; "><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7be4800529988-1" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">1</div></div></td><td class="urvanov-syntax-highlighter-code" style="box-sizing: border-box; padding: 0px !important; text-align: left; font-size: 0.9em; border: none !important; background: none !important; font-family: Verdana, Arial, sans !important; width: 940.583px; vertical-align: top !important; margin: 0px !important;"><div class="crayon-pre" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: none !important; border: none !important; padding: 0px; margin: 0px; text-align: left; color: rgb(0, 0, 0); white-space: pre; overflow: visible; tab-size: 4; font-size: 12px !important; "><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7be4800529988-1" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-i" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 0, 0) !important;">MsgBox</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">x</span></div></div></td></tr></tbody></table></div></div><p style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;">Теперь весь код выбора случайной ячейки из выделенного диапазона и присвоения ее значения переменной в сборе:</p><div id="urvanov-syntax-highlighter-6500a3a6a7be6720320692" class="urvanov-syntax-highlighter-syntax crayon-theme-classic urvanov-syntax-highlighter-font-verdana urvanov-syntax-highlighter-os-pc print-yes notranslate" data-settings=" no-popup minimize scroll-always" style="box-sizing: border-box; text-align: left; text-size-adjust: none; overflow: hidden !important; position: relative !important; direction: ltr !important; width: 960px; padding: 0px; margin: 12px 0px; font-family: Monaco, MonacoRegular, &quot;Courier New&quot;, monospace; font-weight: 500; border-width: 1px !important; border-color: rgb(153, 153, 153) !important; border-style: solid !important; text-shadow: none !important; background: rgb(253, 253, 253) !important; font-size: 12px !important;  height: auto;"><div class="urvanov-syntax-highlighter-plain-wrap" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px !important; margin: 0px !important; text-align: left; height: auto !important;"></div><div class="urvanov-syntax-highlighter-main" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px; margin: 0px; text-align: left; width: 958.222px; overflow: auto; position: relative; z-index: 1;"><table class="crayon-table" style="box-sizing: border-box; border-collapse: collapse !important; border-spacing: 0px !important; border: none !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px; width: auto !important; word-break: initial; font-family: Verdana, Arial, sans !important; padding: 0px !important; background: none !important; table-layout: auto !important;"><tbody style="box-sizing: border-box; font-family: Verdana, Arial, sans !important;"><tr class="urvanov-syntax-highlighter-row" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; padding: 0px !important; border: none !important; background: none !important; vertical-align: top !important; margin: 0px !important;"><td class="crayon-nums " data-settings="show" style="box-sizing: border-box; padding: 0px !important; text-align: left; font-size: 0.9em; border: none !important; background: rgb(223, 239, 255) !important; font-family: Verdana, Arial, sans !important; user-select: none; vertical-align: top !important; margin: 0px !important; color: rgb(84, 153, 222) !important;"><div class="urvanov-syntax-highlighter-nums-content" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px; margin: 0px; text-align: left; white-space: nowrap; font-size: 12px !important; "><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7be6720320692-1" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">1</div><div class="crayon-num crayon-striped-num" data-line="urvanov-syntax-highlighter-6500a3a6a7be6720320692-2" style="box-sizing: border-box; font-family: inherit; background: rgb(200, 225, 250) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(49, 124, 197) !important;">2</div><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7be6720320692-3" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">3</div><div class="crayon-num crayon-striped-num" data-line="urvanov-syntax-highlighter-6500a3a6a7be6720320692-4" style="box-sizing: border-box; font-family: inherit; background: rgb(200, 225, 250) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(49, 124, 197) !important;">4</div><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7be6720320692-5" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">5</div><div class="crayon-num crayon-striped-num" data-line="urvanov-syntax-highlighter-6500a3a6a7be6720320692-6" style="box-sizing: border-box; font-family: inherit; background: rgb(200, 225, 250) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(49, 124, 197) !important;">6</div><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7be6720320692-7" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">7</div><div class="crayon-num crayon-striped-num" data-line="urvanov-syntax-highlighter-6500a3a6a7be6720320692-8" style="box-sizing: border-box; font-family: inherit; background: rgb(200, 225, 250) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(49, 124, 197) !important;">8</div></div></td><td class="urvanov-syntax-highlighter-code" style="box-sizing: border-box; padding: 0px !important; text-align: left; font-size: 0.9em; border: none !important; background: none !important; font-family: Verdana, Arial, sans !important; width: 940.583px; vertical-align: top !important; margin: 0px !important;"><div class="crayon-pre" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: none !important; border: none !important; padding: 0px; margin: 0px; text-align: left; color: rgb(0, 0, 0); white-space: pre; overflow: visible; tab-size: 4; font-size: 12px !important; "><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7be6720320692-1" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-m" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Private</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-t" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Sub</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">CommandButton1_Click</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">(</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">)</span></div><div class="crayon-line crayon-striped-line" id="urvanov-syntax-highlighter-6500a3a6a7be6720320692-2" style="box-sizing: border-box; font-family: inherit; background: rgb(247, 247, 247) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-r" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Dim</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-i" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 0, 0) !important;">x</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">As</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-r" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Variant</span></div><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7be6720320692-3" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">x</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">=</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">Selection</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">.</span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">Count</span></div><div class="crayon-line crayon-striped-line" id="urvanov-syntax-highlighter-6500a3a6a7be6720320692-4" style="box-sizing: border-box; font-family: inherit; background: rgb(247, 247, 247) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-i" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 0, 0) !important;">Randomize</span></div><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7be6720320692-5" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">x</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">=</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">Round</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">(</span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">Rnd</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">*</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">(</span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">x</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">-</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-cn" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(206, 0, 0) !important;">1</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">)</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">,</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-cn" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(206, 0, 0) !important;">0</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">)</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">+</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-cn" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(206, 0, 0) !important;">1</span></div><div class="crayon-line crayon-striped-line" id="urvanov-syntax-highlighter-6500a3a6a7be6720320692-6" style="box-sizing: border-box; font-family: inherit; background: rgb(247, 247, 247) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">x</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">=</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">Selection</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">.</span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">Cells</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">(</span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">x</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">)</span></div><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7be6720320692-7" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-i" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 0, 0) !important;">MsgBox</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-i" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 0, 0) !important;">x</span></div><div class="crayon-line crayon-striped-line" id="urvanov-syntax-highlighter-6500a3a6a7be6720320692-8" style="box-sizing: border-box; font-family: inherit; background: rgb(247, 247, 247) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">End</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-t" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Sub</span></div></div></td></tr></tbody></table></div></div><p style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;">И тот же код VBA Excel в сокращенном виде:</p><div id="urvanov-syntax-highlighter-6500a3a6a7be9845619454" class="urvanov-syntax-highlighter-syntax crayon-theme-classic urvanov-syntax-highlighter-font-verdana urvanov-syntax-highlighter-os-pc print-yes notranslate" data-settings=" no-popup minimize scroll-always" style="box-sizing: border-box; text-align: left; text-size-adjust: none; overflow: hidden !important; position: relative !important; direction: ltr !important; width: 960px; padding: 0px; margin: 12px 0px; font-family: Monaco, MonacoRegular, &quot;Courier New&quot;, monospace; font-weight: 500; border-width: 1px !important; border-color: rgb(153, 153, 153) !important; border-style: solid !important; text-shadow: none !important; background: rgb(253, 253, 253) !important; font-size: 12px !important;  height: auto;"><div class="urvanov-syntax-highlighter-plain-wrap" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px !important; margin: 0px !important; text-align: left; height: auto !important;"></div><div class="urvanov-syntax-highlighter-main" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px; margin: 0px; text-align: left; width: 958.222px; overflow: auto; position: relative; z-index: 1;"><table class="crayon-table" style="box-sizing: border-box; border-collapse: collapse !important; border-spacing: 0px !important; border: none !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px; width: auto !important; word-break: initial; font-family: Verdana, Arial, sans !important; padding: 0px !important; background: none !important; table-layout: auto !important;"><tbody style="box-sizing: border-box; font-family: Verdana, Arial, sans !important;"><tr class="urvanov-syntax-highlighter-row" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; padding: 0px !important; border: none !important; background: none !important; vertical-align: top !important; margin: 0px !important;"><td class="crayon-nums " data-settings="show" style="box-sizing: border-box; padding: 0px !important; text-align: left; font-size: 0.9em; border: none !important; background: rgb(223, 239, 255) !important; font-family: Verdana, Arial, sans !important; user-select: none; vertical-align: top !important; margin: 0px !important; color: rgb(84, 153, 222) !important;"><div class="urvanov-syntax-highlighter-nums-content" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px; margin: 0px; text-align: left; white-space: nowrap; font-size: 12px !important; "><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7be9845619454-1" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">1</div><div class="crayon-num crayon-striped-num" data-line="urvanov-syntax-highlighter-6500a3a6a7be9845619454-2" style="box-sizing: border-box; font-family: inherit; background: rgb(200, 225, 250) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(49, 124, 197) !important;">2</div><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7be9845619454-3" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">3</div><div class="crayon-num crayon-striped-num" data-line="urvanov-syntax-highlighter-6500a3a6a7be9845619454-4" style="box-sizing: border-box; font-family: inherit; background: rgb(200, 225, 250) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(49, 124, 197) !important;">4</div><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7be9845619454-5" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">5</div><div class="crayon-num crayon-striped-num" data-line="urvanov-syntax-highlighter-6500a3a6a7be9845619454-6" style="box-sizing: border-box; font-family: inherit; background: rgb(200, 225, 250) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(49, 124, 197) !important;">6</div></div></td><td class="urvanov-syntax-highlighter-code" style="box-sizing: border-box; padding: 0px !important; text-align: left; font-size: 0.9em; border: none !important; background: none !important; font-family: Verdana, Arial, sans !important; width: 940.583px; vertical-align: top !important; margin: 0px !important;"><div class="crayon-pre" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: none !important; border: none !important; padding: 0px; margin: 0px; text-align: left; color: rgb(0, 0, 0); white-space: pre; overflow: visible; tab-size: 4; font-size: 12px !important; "><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7be9845619454-1" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-m" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Private</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-t" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Sub</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">CommandButton1_Click</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">(</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">)</span></div><div class="crayon-line crayon-striped-line" id="urvanov-syntax-highlighter-6500a3a6a7be9845619454-2" style="box-sizing: border-box; font-family: inherit; background: rgb(247, 247, 247) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-r" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Dim</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-i" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 0, 0) !important;">x</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">As</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-r" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Variant</span></div><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7be9845619454-3" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-i" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 0, 0) !important;">Randomize</span></div><div class="crayon-line crayon-striped-line" id="urvanov-syntax-highlighter-6500a3a6a7be9845619454-4" style="box-sizing: border-box; font-family: inherit; background: rgb(247, 247, 247) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">x</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">=</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">Selection</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">.</span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">Cells</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">(</span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">Round</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">(</span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">Rnd</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">*</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">(</span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">Selection</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">.</span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">Count</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">-</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-cn" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(206, 0, 0) !important;">1</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">)</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">,</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-cn" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(206, 0, 0) !important;">0</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">)</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">+</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-cn" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(206, 0, 0) !important;">1</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">)</span></div><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7be9845619454-5" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-i" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 0, 0) !important;">MsgBox</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-i" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 0, 0) !important;">x</span></div><div class="crayon-line crayon-striped-line" id="urvanov-syntax-highlighter-6500a3a6a7be9845619454-6" style="box-sizing: border-box; font-family: inherit; background: rgb(247, 247, 247) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">End</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-t" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Sub</span></div></div></td></tr></tbody></table></div></div><p style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;"></p><h2 style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; font-size: var(--h2fontsize); font-weight: var(--h2fontweight); font-family: var(--headingsfontfamily),var(--nv-fallback-ff);  letter-spacing: var(--h2letterspacing); text-transform: var(--h2texttransform);"><span id="Zapolnenie_aceek_slucajnymi_cislami" style="box-sizing: border-box;">Заполнение ячеек случайными числами</span></h2><h3 style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; font-size: var(--h3fontsize); font-weight: var(--h3fontweight); font-family: var(--headingsfontfamily),var(--nv-fallback-ff);  letter-spacing: var(--h3letterspacing); text-transform: var(--h3texttransform);"><span id="Zadanie1" style="box-sizing: border-box;">Задание</span></h3><p style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;">Необходимо заполнить произвольный диапазон ячеек случайными числами с помощью кода VBA Excel.</p><h3 style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; font-size: var(--h3fontsize); font-weight: var(--h3fontweight); font-family: var(--headingsfontfamily),var(--nv-fallback-ff);  letter-spacing: var(--h3letterspacing); text-transform: var(--h3texttransform);"><span id="Resenie1" style="box-sizing: border-box;">Решение</span></h3><p style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;">В качестве заданного диапазона, как и в предыдущем решении, будем использовать блок выделенных ячеек. Пройти по всем ячейкам диапазона из кода VBA Excel нам поможет<span> </span><a href="https://vremya-ne-zhdet.ru/vba-excel/tsikl-for-each-next/" style="box-sizing: border-box; --linkdeco: underline; color: var(--nv-primary-accent); cursor: pointer; text-decoration: var(--linkdeco);">цикл For Each… Next</a>.</p><div id="urvanov-syntax-highlighter-6500a3a6a7bf3040250589" class="urvanov-syntax-highlighter-syntax crayon-theme-classic urvanov-syntax-highlighter-font-verdana urvanov-syntax-highlighter-os-pc print-yes notranslate" data-settings=" no-popup minimize scroll-always" style="box-sizing: border-box; text-align: left; text-size-adjust: none; overflow: hidden !important; position: relative !important; direction: ltr !important; width: 960px; padding: 0px; margin: 12px 0px; font-family: Monaco, MonacoRegular, &quot;Courier New&quot;, monospace; font-weight: 500; border-width: 1px !important; border-color: rgb(153, 153, 153) !important; border-style: solid !important; text-shadow: none !important; background: rgb(253, 253, 253) !important; font-size: 12px !important;  height: auto;"><div class="urvanov-syntax-highlighter-plain-wrap" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px !important; margin: 0px !important; text-align: left; height: auto !important;"></div><div class="urvanov-syntax-highlighter-main" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px; margin: 0px; text-align: left; width: 958.222px; overflow: auto; position: relative; z-index: 1;"><table class="crayon-table" style="box-sizing: border-box; border-collapse: collapse !important; border-spacing: 0px !important; border: none !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px; width: auto !important; word-break: initial; font-family: Verdana, Arial, sans !important; padding: 0px !important; background: none !important; table-layout: auto !important;"><tbody style="box-sizing: border-box; font-family: Verdana, Arial, sans !important;"><tr class="urvanov-syntax-highlighter-row" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; padding: 0px !important; border: none !important; background: none !important; vertical-align: top !important; margin: 0px !important;"><td class="crayon-nums " data-settings="show" style="box-sizing: border-box; padding: 0px !important; text-align: left; font-size: 0.9em; border: none !important; background: rgb(223, 239, 255) !important; font-family: Verdana, Arial, sans !important; user-select: none; vertical-align: top !important; margin: 0px !important; color: rgb(84, 153, 222) !important;"><div class="urvanov-syntax-highlighter-nums-content" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px; margin: 0px; text-align: left; white-space: nowrap; font-size: 12px !important; "><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf3040250589-1" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">1</div><div class="crayon-num crayon-striped-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf3040250589-2" style="box-sizing: border-box; font-family: inherit; background: rgb(200, 225, 250) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(49, 124, 197) !important;">2</div><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf3040250589-3" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">3</div><div class="crayon-num crayon-striped-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf3040250589-4" style="box-sizing: border-box; font-family: inherit; background: rgb(200, 225, 250) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(49, 124, 197) !important;">4</div><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf3040250589-5" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">5</div><div class="crayon-num crayon-striped-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf3040250589-6" style="box-sizing: border-box; font-family: inherit; background: rgb(200, 225, 250) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(49, 124, 197) !important;">6</div><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf3040250589-7" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">7</div></div></td><td class="urvanov-syntax-highlighter-code" style="box-sizing: border-box; padding: 0px !important; text-align: left; font-size: 0.9em; border: none !important; background: none !important; font-family: Verdana, Arial, sans !important; width: 940.583px; vertical-align: top !important; margin: 0px !important;"><div class="crayon-pre" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: none !important; border: none !important; padding: 0px; margin: 0px; text-align: left; color: rgb(0, 0, 0); white-space: pre; overflow: visible; tab-size: 4; font-size: 12px !important; "><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7bf3040250589-1" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-m" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Private</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-t" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Sub</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">CommandButton1_Click</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">(</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">)</span></div><div class="crayon-line crayon-striped-line" id="urvanov-syntax-highlighter-6500a3a6a7bf3040250589-2" style="box-sizing: border-box; font-family: inherit; background: rgb(247, 247, 247) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-r" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Dim</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">myCell </span><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">As</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">Range</span></div><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7bf3040250589-3" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">Randomize</span></div><div class="crayon-line crayon-striped-line" id="urvanov-syntax-highlighter-6500a3a6a7bf3040250589-4" style="box-sizing: border-box; font-family: inherit; background: rgb(247, 247, 247) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">    </span><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">For</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Each</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">myCell </span><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">In</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">Selection</span></div><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7bf3040250589-5" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">        </span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">myCell</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">=</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">Round</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">(</span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">Rnd</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">*</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-cn" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(206, 0, 0) !important;">10000</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">,</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-cn" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(206, 0, 0) !important;">0</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">)</span></div><div class="crayon-line crayon-striped-line" id="urvanov-syntax-highlighter-6500a3a6a7bf3040250589-6" style="box-sizing: border-box; font-family: inherit; background: rgb(247, 247, 247) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">    </span><span class="crayon-r" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Next</span></div><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7bf3040250589-7" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">End</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-t" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Sub</span></div></div></td></tr></tbody></table></div></div><div class="google-auto-placed ap_container" style="box-sizing: border-box; width: 960px; height: auto; clear: both; text-align: center;"><ins data-ad-format="auto" class="adsbygoogle adsbygoogle-noablate" data-ad-client="ca-pub-3460721053602142" data-adsbygoogle-status="done" data-ad-status="unfilled" style="box-sizing: border-box; text-decoration: none; display: block; margin: auto; background-color: transparent; height: 0px;"><div id="aswift_2_host" tabindex="0" title="Advertisement" aria-label="Advertisement" style="box-sizing: border-box; border: none; height: 0px; width: 960px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: inline-block; overflow: hidden; opacity: 0;"><iframe id="aswift_2" name="aswift_2" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" width="960" height="0" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" src="https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-3460721053602142&amp;output=html&amp;h=280&amp;adk=4198996889&amp;adf=462784580&amp;pi=t.aa~a.2994879612~i.131~rp.4&amp;w=960&amp;fwrn=4&amp;fwrnh=100&amp;lmt=1694542435&amp;num_ads=1&amp;rafmt=1&amp;armr=3&amp;sem=mc&amp;pwprc=9507011714&amp;ad_type=text_image&amp;format=960x280&amp;url=https%3A%2F%2Fvremya-ne-zhdet.ru%2Fvba-excel%2Fvybor-sluchaynoy-yacheyki%2F&amp;fwr=0&amp;pra=3&amp;rh=200&amp;rw=960&amp;rpe=1&amp;resp_fmts=3&amp;wgl=1&amp;fa=27&amp;uach=WyJXaW5kb3dzIiwiMTUuMC4wIiwieDg2IiwiIiwiMjMuNy40Ljk3MSIsW10sMCxudWxsLCI2NCIsW1siTm90LkEvQnJhbmQiLCI4LjAuMC4wIl0sWyJDaHJvbWl1bSIsIjExNC4wLjU3MzUuMjg5Il0sWyJZYUJyb3dzZXIiLCIyMy43LjQuOTcxIl1dLDBd&amp;dt=1694540732865&amp;bpp=1&amp;bdt=21047&amp;idt=1&amp;shv=r20230907&amp;mjsv=m202309120101&amp;ptt=9&amp;saldr=aa&amp;abxe=1&amp;cookie=ID%3Db9bebb71368c25f3-2201b9ef68de007a%3AT%3D1694115878%3ART%3D1694540739%3AS%3DALNI_Ma3frN0cXirUHyuAOLWfMkqZEMxuA&amp;gpic=UID%3D00000d90c82ba053%3AT%3D1694115878%3ART%3D1694540739%3AS%3DALNI_MYSu2HMUV4-wrBhZkUsdUg0v0y7zw&amp;prev_fmts=0x0%2C960x280&amp;nras=3&amp;correlator=8553361513783&amp;frm=20&amp;pv=1&amp;ga_vid=133512174.1694115766&amp;ga_sid=1694540721&amp;ga_hid=1247311596&amp;ga_fc=1&amp;u_tz=180&amp;u_his=2&amp;u_h=864&amp;u_w=1536&amp;u_ah=816&amp;u_aw=1536&amp;u_cd=24&amp;u_sd=1.125&amp;dmc=8&amp;adx=337&amp;ady=3399&amp;biw=1635&amp;bih=796&amp;scr_x=0&amp;scr_y=254&amp;eid=44759875%2C44759926%2C44759842%2C31077327%2C31077838&amp;oid=2&amp;pvsid=3453566974728970&amp;tmod=371194068&amp;uas=0&amp;nvt=1&amp;ref=https%3A%2F%2Fvremya-ne-zhdet.ru%2Fcategory%2Fvba-excel%2Fpage%2F7%2F&amp;fc=1408&amp;brdim=0%2C0%2C0%2C0%2C1536%2C0%2C1536%2C816%2C1653%2C796&amp;vis=1&amp;rsz=%7C%7Cs%7C&amp;abl=NS&amp;fu=128&amp;bc=31&amp;ifi=3&amp;uci=a!3&amp;btvi=2&amp;fsb=1&amp;xpc=ju1vEa5EAI&amp;p=https%3A//vremya-ne-zhdet.ru&amp;dtd=M" data-google-container-id="a!3" data-google-query-id="CM_y877WpYEDFcZZkQUdYw0OHw" data-load-complete="true" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; max-width: 100%; left: 0px; position: absolute; top: 0px; width: 960px; height: 0px;"></iframe></div></ins></div><p style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;">Этот код заполняет по очереди все ячейки выделенного диапазона случайными числами в интервале от 0 до 10000. После нажатия кнопки процесс заполнения виден визуально, но его можно ускорить.</p><p style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;">Для ускорения заполнения ячеек случайными числами можно использовать<span> </span><a href="https://vremya-ne-zhdet.ru/vba-excel/massivy/" style="box-sizing: border-box; --linkdeco: underline; color: var(--nv-primary-accent); cursor: pointer; text-decoration: var(--linkdeco);">массив</a>, циклы в котором работают значительно быстрее, чем при переборе ячеек в диапазоне.</p><div id="urvanov-syntax-highlighter-6500a3a6a7bf8020977366" class="urvanov-syntax-highlighter-syntax crayon-theme-classic urvanov-syntax-highlighter-font-verdana urvanov-syntax-highlighter-os-pc print-yes notranslate" data-settings=" no-popup minimize scroll-always" style="box-sizing: border-box; text-align: left; text-size-adjust: none; overflow: hidden !important; position: relative !important; direction: ltr !important; width: 960px; padding: 0px; margin: 12px 0px; font-family: Monaco, MonacoRegular, &quot;Courier New&quot;, monospace; font-weight: 500; border-width: 1px !important; border-color: rgb(153, 153, 153) !important; border-style: solid !important; text-shadow: none !important; background: rgb(253, 253, 253) !important; font-size: 12px !important;  height: auto;"><div class="urvanov-syntax-highlighter-plain-wrap" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px !important; margin: 0px !important; text-align: left; height: auto !important;"></div><div class="urvanov-syntax-highlighter-main" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px; margin: 0px; text-align: left; width: 958.222px; overflow: auto; position: relative; z-index: 1;"><table class="crayon-table" style="box-sizing: border-box; border-collapse: collapse !important; border-spacing: 0px !important; border: none !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px; width: auto !important; word-break: initial; font-family: Verdana, Arial, sans !important; padding: 0px !important; background: none !important; table-layout: auto !important;"><tbody style="box-sizing: border-box; font-family: Verdana, Arial, sans !important;"><tr class="urvanov-syntax-highlighter-row" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; padding: 0px !important; border: none !important; background: none !important; vertical-align: top !important; margin: 0px !important;"><td class="crayon-nums " data-settings="show" style="box-sizing: border-box; padding: 0px !important; text-align: left; font-size: 0.9em; border: none !important; background: rgb(223, 239, 255) !important; font-family: Verdana, Arial, sans !important; user-select: none; vertical-align: top !important; margin: 0px !important; color: rgb(84, 153, 222) !important;"><div class="urvanov-syntax-highlighter-nums-content" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: 0px center; border: 0px; padding: 0px; margin: 0px; text-align: left; white-space: nowrap; font-size: 12px !important; "><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-1" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">1</div><div class="crayon-num crayon-striped-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-2" style="box-sizing: border-box; font-family: inherit; background: rgb(200, 225, 250) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(49, 124, 197) !important;">2</div><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-3" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">3</div><div class="crayon-num crayon-striped-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-4" style="box-sizing: border-box; font-family: inherit; background: rgb(200, 225, 250) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(49, 124, 197) !important;">4</div><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-5" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">5</div><div class="crayon-num crayon-striped-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-6" style="box-sizing: border-box; font-family: inherit; background: rgb(200, 225, 250) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(49, 124, 197) !important;">6</div><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-7" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">7</div><div class="crayon-num crayon-striped-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-8" style="box-sizing: border-box; font-family: inherit; background: rgb(200, 225, 250) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(49, 124, 197) !important;">8</div><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-9" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">9</div><div class="crayon-num crayon-striped-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-10" style="box-sizing: border-box; font-family: inherit; background: rgb(200, 225, 250) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(49, 124, 197) !important;">10</div><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-11" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">11</div><div class="crayon-num crayon-striped-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-12" style="box-sizing: border-box; font-family: inherit; background: rgb(200, 225, 250) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(49, 124, 197) !important;">12</div><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-13" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">13</div><div class="crayon-num crayon-striped-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-14" style="box-sizing: border-box; font-family: inherit; background: rgb(200, 225, 250) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(49, 124, 197) !important;">14</div><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-15" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">15</div><div class="crayon-num crayon-striped-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-16" style="box-sizing: border-box; font-family: inherit; background: rgb(200, 225, 250) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(49, 124, 197) !important;">16</div><div class="crayon-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-17" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important;">17</div><div class="crayon-num crayon-striped-num" data-line="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-18" style="box-sizing: border-box; font-family: inherit; background: rgb(200, 225, 250) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: center; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(49, 124, 197) !important;">18</div></div></td><td class="urvanov-syntax-highlighter-code" style="box-sizing: border-box; padding: 0px !important; text-align: left; font-size: 0.9em; border: none !important; background: none !important; font-family: Verdana, Arial, sans !important; width: 932.958px; vertical-align: top !important; margin: 0px !important;"><div class="crayon-pre" style="box-sizing: border-box; font-family: Verdana, Arial, sans !important; background: none !important; border: none !important; padding: 0px; margin: 0px; text-align: left; color: rgb(0, 0, 0); white-space: pre; overflow: visible; tab-size: 4; font-size: 12px !important; "><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-1" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-m" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Private</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-t" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Sub</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">CommandButton1_Click</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">(</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">)</span></div><div class="crayon-line crayon-striped-line" id="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-2" style="box-sizing: border-box; font-family: inherit; background: rgb(247, 247, 247) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-r" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Dim</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">massiv</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">(</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">)</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">As</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-r" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Variant</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">,</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">n1 </span><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">As</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-t" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Long</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">,</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">n2 </span><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">As</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-t" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Long</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">,</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">i1 </span><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">As</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-t" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Long</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">,</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">i2 </span><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">As</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-t" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Long</span></div><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-3" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">    </span><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">If</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">Selection</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">.</span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">Count</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">=</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-cn" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(206, 0, 0) !important;">1</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Then</span></div><div class="crayon-line crayon-striped-line" id="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-4" style="box-sizing: border-box; font-family: inherit; background: rgb(247, 247, 247) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">        </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">Randomize</span></div><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-5" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">        </span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">Selection</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">=</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">Round</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">(</span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">Rnd</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">*</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-cn" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(206, 0, 0) !important;">10000</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">,</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-cn" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(206, 0, 0) !important;">0</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">)</span></div><div class="crayon-line crayon-striped-line" id="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-6" style="box-sizing: border-box; font-family: inherit; background: rgb(247, 247, 247) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">    </span><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Else</span></div><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-7" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">        </span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">massiv</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">=</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">Selection</span></div><div class="crayon-line crayon-striped-line" id="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-8" style="box-sizing: border-box; font-family: inherit; background: rgb(247, 247, 247) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">        </span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">n1</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">=</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">UBound</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">(</span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">massiv</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">,</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-cn" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(206, 0, 0) !important;">1</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">)</span></div><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-9" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">        </span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">n2</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">=</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">UBound</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">(</span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">massiv</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">,</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-cn" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(206, 0, 0) !important;">2</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">)</span></div><div class="crayon-line crayon-striped-line" id="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-10" style="box-sizing: border-box; font-family: inherit; background: rgb(247, 247, 247) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">        </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">Randomize</span></div><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-11" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">            </span><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">For</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">i1</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">=</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-cn" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(206, 0, 0) !important;">1</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">To</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">n1</span></div><div class="crayon-line crayon-striped-line" id="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-12" style="box-sizing: border-box; font-family: inherit; background: rgb(247, 247, 247) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">                </span><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">For</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">i2</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">=</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-cn" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(206, 0, 0) !important;">1</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">To</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">n2</span></div><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-13" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">                   </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">massiv</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">(</span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">i1</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">,</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">i2</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">)</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">=</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">Round</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">(</span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">Rnd</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">*</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-cn" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(206, 0, 0) !important;">10000</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">,</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-cn" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(206, 0, 0) !important;">0</span><span class="crayon-sy" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(51, 51, 51) !important;">)</span></div><div class="crayon-line crayon-striped-line" id="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-14" style="box-sizing: border-box; font-family: inherit; background: rgb(247, 247, 247) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">                </span><span class="crayon-r" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Next</span></div><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-15" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">            </span><span class="crayon-r" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Next</span></div><div class="crayon-line crayon-striped-line" id="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-16" style="box-sizing: border-box; font-family: inherit; background: rgb(247, 247, 247) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">        </span><span class="crayon-v" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 45, 122) !important;">Selection</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-o" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;">=</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">massiv</span></div><div class="crayon-line" id="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-17" style="box-sizing: border-box; font-family: inherit; background: 0px center; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-e" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 78, 208) !important;">    </span><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">End</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">If</span></div><div class="crayon-line crayon-striped-line" id="urvanov-syntax-highlighter-6500a3a6a7bf8020977366-18" style="box-sizing: border-box; font-family: inherit; background: rgb(247, 247, 247) !important; border: 0px; padding: 0px 5px; margin: 0px; text-align: left; height: inherit; font-size: inherit !important;  font-weight: inherit !important;"><span class="crayon-st" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">End</span><span class="crayon-h" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(0, 111, 224) !important;"> </span><span class="crayon-t" style="box-sizing: border-box; font-family: inherit; height: inherit; font-size: inherit !important;  font-weight: inherit !important; color: rgb(128, 0, 128) !important;">Sub</span></div></div></td></tr></tbody></table></div></div><div class="google-auto-placed ap_container" style="box-sizing: border-box; width: 960px; height: auto; clear: both; text-align: center;"><ins data-ad-format="auto" class="adsbygoogle adsbygoogle-noablate" data-ad-client="ca-pub-3460721053602142" data-adsbygoogle-status="done" data-ad-status="unfilled" style="box-sizing: border-box; text-decoration: none; display: block; margin: auto; background-color: transparent; height: 0px;"><div id="aswift_3_host" tabindex="0" title="Advertisement" aria-label="Advertisement" style="box-sizing: border-box; border: none; height: 0px; width: 960px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: inline-block; overflow: hidden; opacity: 0;"><iframe id="aswift_3" name="aswift_3" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" width="960" height="0" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" src="https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-3460721053602142&amp;output=html&amp;h=280&amp;adk=4198996889&amp;adf=41856136&amp;pi=t.aa~a.2994879612~i.144~rp.4&amp;w=960&amp;fwrn=4&amp;fwrnh=100&amp;lmt=1694542437&amp;num_ads=1&amp;rafmt=1&amp;armr=3&amp;sem=mc&amp;pwprc=9507011714&amp;ad_type=text_image&amp;format=960x280&amp;url=https%3A%2F%2Fvremya-ne-zhdet.ru%2Fvba-excel%2Fvybor-sluchaynoy-yacheyki%2F&amp;fwr=0&amp;pra=3&amp;rh=200&amp;rw=960&amp;rpe=1&amp;resp_fmts=3&amp;wgl=1&amp;fa=27&amp;uach=WyJXaW5kb3dzIiwiMTUuMC4wIiwieDg2IiwiIiwiMjMuNy40Ljk3MSIsW10sMCxudWxsLCI2NCIsW1siTm90LkEvQnJhbmQiLCI4LjAuMC4wIl0sWyJDaHJvbWl1bSIsIjExNC4wLjU3MzUuMjg5Il0sWyJZYUJyb3dzZXIiLCIyMy43LjQuOTcxIl1dLDBd&amp;dt=1694540732871&amp;bpp=1&amp;bdt=21054&amp;idt=1&amp;shv=r20230907&amp;mjsv=m202309120101&amp;ptt=9&amp;saldr=aa&amp;abxe=1&amp;cookie=ID%3Db9bebb71368c25f3-2201b9ef68de007a%3AT%3D1694115878%3ART%3D1694540739%3AS%3DALNI_Ma3frN0cXirUHyuAOLWfMkqZEMxuA&amp;gpic=UID%3D00000d90c82ba053%3AT%3D1694115878%3ART%3D1694540739%3AS%3DALNI_MYSu2HMUV4-wrBhZkUsdUg0v0y7zw&amp;prev_fmts=0x0%2C960x280%2C960x280&amp;nras=4&amp;correlator=8553361513783&amp;frm=20&amp;pv=1&amp;ga_vid=133512174.1694115766&amp;ga_sid=1694540721&amp;ga_hid=1247311596&amp;ga_fc=1&amp;u_tz=180&amp;u_his=2&amp;u_h=864&amp;u_w=1536&amp;u_ah=816&amp;u_aw=1536&amp;u_cd=24&amp;u_sd=1.125&amp;dmc=8&amp;adx=337&amp;ady=3851&amp;biw=1635&amp;bih=796&amp;scr_x=0&amp;scr_y=673&amp;eid=44759875%2C44759926%2C44759842%2C31077327%2C31077838&amp;oid=2&amp;pvsid=3453566974728970&amp;tmod=371194068&amp;uas=0&amp;nvt=1&amp;ref=https%3A%2F%2Fvremya-ne-zhdet.ru%2Fcategory%2Fvba-excel%2Fpage%2F7%2F&amp;fc=1408&amp;brdim=0%2C0%2C0%2C0%2C1536%2C0%2C1536%2C816%2C1653%2C796&amp;vis=1&amp;rsz=%7C%7Cs%7C&amp;abl=NS&amp;fu=128&amp;bc=31&amp;ifi=4&amp;uci=a!4&amp;btvi=3&amp;fsb=1&amp;xpc=KrGI6mekcF&amp;p=https%3A//vremya-ne-zhdet.ru&amp;dtd=M" data-google-container-id="a!4" data-google-query-id="CLmoh8DWpYEDFaVQkQUd_T0JUg" data-load-complete="true" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; max-width: 100%; left: 0px; position: absolute; top: 0px; width: 960px; height: 0px;"></iframe></div></ins></div><p style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;">При запуске этого кода VBA Excel ячейки выбранного диапазона заполнятся случайными числами практически мгновенно.</p><div class="google-auto-placed ap_container" style="box-sizing: border-box; width: 960px; height: auto; clear: both; text-align: center;"><ins data-ad-format="auto" class="adsbygoogle adsbygoogle-noablate" data-ad-client="ca-pub-3460721053602142" data-adsbygoogle-status="done" data-ad-status="unfilled" style="box-sizing: border-box; text-decoration: none; display: block; margin: auto; background-color: transparent; height: 0px;"><div id="aswift_4_host" tabindex="0" title="Advertisement" aria-label="Advertisement" style="box-sizing: border-box; border: none; height: 0px; width: 960px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: inline-block; overflow: hidden; opacity: 0;"><iframe id="aswift_4" name="aswift_4" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" width="960" height="0" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" src="https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-3460721053602142&amp;output=html&amp;h=280&amp;adk=4198996889&amp;adf=3339947056&amp;pi=t.aa~a.2994879612~i.148~rp.4&amp;w=960&amp;fwrn=4&amp;fwrnh=100&amp;lmt=1694542437&amp;num_ads=1&amp;rafmt=1&amp;armr=3&amp;sem=mc&amp;pwprc=9507011714&amp;ad_type=text_image&amp;format=960x280&amp;url=https%3A%2F%2Fvremya-ne-zhdet.ru%2Fvba-excel%2Fvybor-sluchaynoy-yacheyki%2F&amp;fwr=0&amp;pra=3&amp;rh=200&amp;rw=960&amp;rpe=1&amp;resp_fmts=3&amp;wgl=1&amp;fa=27&amp;uach=WyJXaW5kb3dzIiwiMTUuMC4wIiwieDg2IiwiIiwiMjMuNy40Ljk3MSIsW10sMCxudWxsLCI2NCIsW1siTm90LkEvQnJhbmQiLCI4LjAuMC4wIl0sWyJDaHJvbWl1bSIsIjExNC4wLjU3MzUuMjg5Il0sWyJZYUJyb3dzZXIiLCIyMy43LjQuOTcxIl1dLDBd&amp;dt=1694540732878&amp;bpp=1&amp;bdt=21060&amp;idt=1&amp;shv=r20230907&amp;mjsv=m202309120101&amp;ptt=9&amp;saldr=aa&amp;abxe=1&amp;cookie=ID%3Db9bebb71368c25f3-2201b9ef68de007a%3AT%3D1694115878%3ART%3D1694540739%3AS%3DALNI_Ma3frN0cXirUHyuAOLWfMkqZEMxuA&amp;gpic=UID%3D00000d90c82ba053%3AT%3D1694115878%3ART%3D1694540739%3AS%3DALNI_MYSu2HMUV4-wrBhZkUsdUg0v0y7zw&amp;prev_fmts=0x0%2C960x280%2C960x280%2C960x280&amp;nras=5&amp;correlator=8553361513783&amp;frm=20&amp;pv=1&amp;ga_vid=133512174.1694115766&amp;ga_sid=1694540721&amp;ga_hid=1247311596&amp;ga_fc=1&amp;u_tz=180&amp;u_his=2&amp;u_h=864&amp;u_w=1536&amp;u_ah=816&amp;u_aw=1536&amp;u_cd=24&amp;u_sd=1.125&amp;dmc=8&amp;adx=337&amp;ady=3908&amp;biw=1635&amp;bih=796&amp;scr_x=0&amp;scr_y=771&amp;eid=44759875%2C44759926%2C44759842%2C31077327%2C31077838&amp;oid=2&amp;pvsid=3453566974728970&amp;tmod=371194068&amp;uas=0&amp;nvt=1&amp;ref=https%3A%2F%2Fvremya-ne-zhdet.ru%2Fcategory%2Fvba-excel%2Fpage%2F7%2F&amp;fc=1408&amp;brdim=0%2C0%2C0%2C0%2C1536%2C0%2C1536%2C816%2C1653%2C796&amp;vis=1&amp;rsz=%7C%7Cs%7C&amp;abl=NS&amp;cms=2&amp;fu=128&amp;bc=31&amp;ifi=5&amp;uci=a!5&amp;btvi=4&amp;fsb=1&amp;xpc=ylJ6OARHSs&amp;p=https%3A//vremya-ne-zhdet.ru&amp;dtd=M" data-google-container-id="a!5" data-google-query-id="CNzEjcDWpYEDFWdVkQUdTqAGQw" data-load-complete="true" style="box-sizing: border-box; margin: 0px; padding: 0px; border: 0px; max-width: 100%; left: 0px; position: absolute; top: 0px; width: 960px; height: 0px;"></iframe></div></ins></div><p style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;">Условие, проверяющее, не состоит ли диапазон из одной ячейки, необходимо для того, чтобы избежать ошибки, возникающей при присвоении массиву единственного значения из диапазона, состоящего из одной ячейки.</p><p style="box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;">Также стоит учитывать, что максимальный размер массива зависит от операционной системы и доступного объема памяти. Например, если выделить весь рабочий лист и нажать кнопку, произойдет ошибка.</p><div class="blok-fon-3" style="box-sizing: border-box; width: auto; height: auto; padding: 0.4375rem; margin: 0px 0px 1.5rem; background-color: rgb(230, 230, 250);"><a href="https://vremya-ne-zhdet.ru/vba-excel/soderzhaniye-rubriki/" style="box-sizing: border-box; --linkdeco: underline; color: var(--nv-primary-accent); cursor: pointer; text-decoration: var(--linkdeco);">Содержание рубрики VBA Excel</a><span> </span>по тематическим разделам со ссылками на все статьи.</div></div>
</body>
</html></p></body></html>